package com.cmower.journal.cow;

import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class COWDemo {
    public static void main(String[] args) {

//        Collections.synchronizedList();
        List<String> list = new CopyOnWriteArrayList();
        list.add("沉默王二");
        list.add("沉默王三");
        list.add("一个文章真特么有趣的程序员");

        Iterator var2 = list.iterator();

        while(var2.hasNext()) {
            String str = (String)var2.next();
            if ("沉默王二".equals(str)) {
                list.remove(str);
            }
        }

        System.out.println(list);


CopyOnWriteArrayList<String> list1 =
        new CopyOnWriteArrayList<>(new String[] {"沉默王二", "沉默王三"});
Iterator itr = list1.iterator();
list1.add("沉默王四");
while(itr.hasNext()) {
    System.out.print(itr.next() + " ");
}
    }
}
